#ifndef BOUNDINGBOX_H
#define BOUNDINGBOX_H

/**
 * \file	boundingbox.h
 * \brief	Declaration de la classe BoundingBox representant la boite englobate d'un objet en 3 dimensions.
 */

#include "segment.h"

class BoundingBox
{
	/*!
	 * \class BoundingBox
	 * \brief Classe représentant la boite englobante d'un objet en trois dimensions. Elle est caracterisee par ses deux points extremes et peut etre calculee a partir de differents objets (segments, meshes...).
	 *
	 */
	private :
		Vector3D bot;			/*! Extrema point of the bounding box : its x,y and z coordinates are the minimums x,y and z coordinates found in the element to describe by the bounding box.*/
		Vector3D top;			/*! Extrema point of the bounding box : its x,y and z coordinates are the maximums x,y and z coordinates found in the element to describe by the bounding box.*/
	
	public:
		/*!
		*  \brief Default constructor of the BoundingBox class.
		*
		*  Default constructor of the BoundingBox class : Every attributes are initialized to 0 (int,float,double,...) NULL (pointers) or are cleared (lists, stacks, ...).
		*/
		BoundingBox();
		
		/*!
		*  \brief Copy constructor of the BoundingBox class.
		*
		*  Copy constructor of the BoundingBox class : Every attributes are initialized to 0 (int,float,double,...) NULL (pointers) or are cleared (lists, stacks, ...).
		*/
		BoundingBox( const BoundingBox& _bb );
		
		/*!
		*  \brief Destructor of the BoundingBox class.
		*
		*  Destructor of the BoundingBox class : Every attributes are initialized to 0 (int,float,double,...) NULL (pointers) or are cleared (lists, stacks, ...).
		*/
		~BoundingBox();
		
		/*!
		*  \brief Affectation operator of the BoundingBox class.
		*
		*  Affectation operator of the BoundingBox class : Every attributes are initialized to 0 (int,float,double,...) NULL (pointers) or are cleared (lists, stacks, ...).
		*/
		BoundingBox& operator= ( const BoundingBox& _bb );
		
		/*!
		*  \brief Getter of the BoundingBox class.
		*
		*  Getter of the BoundingBox class.
		*
		*  \return (Vector3D) Returns the minimum point of the box.
		*/
		Vector3D getBot ();
		
		/*!
		*  \brief Getter of the BoundingBox class.
		*
		*  Getter of the BoundingBox class.
		*
		*  \return (Vector3D) Returns the maximum point of the box.
		*/
		Vector3D getTop ();
		
		/*!
		*  \brief Getter of the BoundingBox class.
		*
		*  Getter of the BoundingBox class.
		*
		*  \return (Vector3D) Returns the minimum point of the box as a double array.
		*/
		double* getBotArray ();
		
		/*!
		*  \brief Getter of the BoundingBox class.
		*
		*  Getter of the BoundingBox class.
		*
		*  \return (Vector3D) Returns the maximum point of the box as a double array.
		*/
		double* getTopArray ();
		
		/*!
		*  \brief Setter of the BoundingBox class.
		*
		*  Setter of the BoundingBox class.
		*
		*  \param _bot : Point to set as the minimum point of the box;
		*
		*  \return (void)
		*/
		void setBot ( Vector3D _bot );
		
		/*!
		*  \brief Setter of the BoundingBox class.
		*
		*  Setter of the BoundingBox class.
		*
		*  \param _top : Point to set as the maximum point of the box;
		*
		*  \return (void)
		*/
		void setTop ( Vector3D _top );
		
		/*!
		*  \brief Convert a bounding box coordinates into a per centage of another bounding box coordinates.
		*
		*  Convert a bounding box coordinates into a per centage of another bounding box coordinates.
		*
		*  \param _bbox : Bounding box to set as a reference for the convertion. (see picture).
		*
		*  \return (void)
		*/
		void convertsTo ( BoundingBox _bbox );
		
		/*!
		*  \brief Creates the bounding box of a mesh.
		*
		*  Creates the bounding box of a mesh.
		*
		*  \param _mesh : Mesh we want to get the bounding box.
		*
		*  \return (void)
		*/
		void create ( Mesh _mesh );
		
		/*!
		*  \brief Creates the bounding box of a mesh.
		*
		*  Creates the bounding box of a mesh.
		*
		*  \param _mesh : Mesh we want to get the bounding box.
		*
		*  \return (void)
		*/
		void create ( Mesh* _mesh );
		
		/*!
		*  \brief Creates the bounding box of a segment.
		*
		*  Creates the bounding box of a segment.
		*
		*  \param _s : Segment we want to get the bounding box.
		*
		*  \return (void)
		*/
		void create ( Segment _s );
		
		/*!
		*  \brief Creates the bounding box of a segment.
		*
		*  Creates the bounding box of a segment.
		*
		*  \param _s : Segment we want to get the bounding box.
		*
		*  \return (void)
		*/
		void create ( Segment* _s );
		
		/*!
		*  \brief Indicates wether or not a bounding bx matches another one within a given criteria.
		*
		*  Indicates wether or not a bounding bx matches another one in a similarity criteria on the bots points along the Ox axe.
		*
		*  \param _bbox : Bounding box  you want to know wether or not is matched.
		*  \param _distMax : Distance maximum for the match to be considered as valid.
		*
		*  \return (bool) Returns true is the match is verified, false else.
		*/
		bool matchBotX ( BoundingBox _bbox, int _distMax );
		
		/*!
		*  \brief Indicates wether or not a bounding bx matches another one within a given criteria.
		*
		*  Indicates wether or not a bounding bx matches another one in a similarity criteria on the bots points along the Oy axe.
		*
		*  \param _bbox : Bounding box  you want to know wether or not is matched.
		*  \param _distMax : Distance maximum for the match to be considered as valid.
		*
		*  \return (bool) Returns true is the match is verified, false else.
		*/
		bool matchBotY ( BoundingBox _bbox, int _distMax );
		
		/*!
		*  \brief Indicates wether or not a bounding bx matches another one within a given criteria.
		*
		*  Indicates wether or not a bounding bx matches another one in a similarity criteria on the bots points along the OZ axe.
		*
		*  \param _bbox : Bounding box  you want to know wether or not is matched.
		*  \param _distMax : Distance maximum for the match to be considered as valid.
		*
		*  \return (bool) Returns true is the match is verified, false else.
		*/
		bool matchBotZ ( BoundingBox _bbox, int _distMax );
		
		/*!
		*  \brief Indicates wether or not a bounding bx matches another one within a given criteria.
		*
		*  Indicates wether or not a bounding bx matches another one in a similarity criteria on the tops points along the Ox axe.
		*
		*  \param _bbox : Bounding box  you want to know wether or not is matched.
		*  \param _distMax : Distance maximum for the match to be considered as valid.
		*
		*  \return (bool) Returns true is the match is verified, false else.
		*/
		bool matchTopX ( BoundingBox _bbox, int _distMax );
		
		/*!
		*  \brief Indicates wether or not a bounding bx matches another one within a given criteria.
		*
		*  Indicates wether or not a bounding bx matches another one in a similarity criteria on the tops points along the Oy axe.
		*
		*  \param _bbox : Bounding box  you want to know wether or not is matched.
		*  \param _distMax : Distance maximum for the match to be considered as valid.
		*
		*  \return (bool) Returns true is the match is verified, false else.
		*/
		bool matchTopY ( BoundingBox _bbox, int _distMax );
		
		/*!
		*  \brief Indicates wether or not a bounding bx matches another one within a given criteria.
		*
		*  Indicates wether or not a bounding bx matches another one in a similarity criteria on the tops points along the OZ axe.
		*
		*  \param _bbox : Bounding box  you want to know wether or not is matched.
		*  \param _distMax : Distance maximum for the match to be considered as valid.
		*
		*  \return (bool) Returns true is the match is verified, false else.
		*/
		bool matchTopZ ( BoundingBox _bbox, int _distMax );
		
		/*!
		*  \brief Indicates wether or not a bounding bx matches another one within a given criteria.
		*
		*  Indicates wether or not a bounding bx matches another one in a similarity criteria on the extremity points along the Ox axe.
		*
		*  \param _bbox : Bounding box  you want to know wether or not is matched.
		*  \param _distMax : Distance maximum for the match to be considered as valid.
		*
		*  \return (bool) Returns true is the match is verified, false else.
		*/
		bool matchX ( BoundingBox _bbox, int _distMax );
		
		/*!
		*  \brief Indicates wether or not a bounding bx matches another one within a given criteria.
		*
		*  Indicates wether or not a bounding bx matches another one in a similarity criteria on the extremity points along the Oy axe.
		*
		*  \param _bbox : Bounding box  you want to know wether or not is matched.
		*  \param _distMax : Distance maximum for the match to be considered as valid.
		*
		*  \return (bool) Returns true is the match is verified, false else.
		*/
		bool matchY ( BoundingBox _bbox, int _distMax );
		
		/*!
		*  \brief Indicates wether or not a bounding bx matches another one within a given criteria.
		*
		*  Indicates wether or not a bounding bx matches another one in a similarity criteria on the extremity points along the Oz axe.
		*
		*  \param _bbox : Bounding box  you want to know wether or not is matched.
		*  \param _distMax : Distance maximum for the match to be considered as valid.
		*
		*  \return (bool) Returns true is the match is verified, false else.
		*/
		bool matchZ ( BoundingBox _bbox, int _distMax );
		
		/*!
		*  \brief Prints the coordinates of the bounding box extremas.
		*
		*  Prints the coordinates of the bounding box extremas.
		*
		*  \return (void)
		*/
		void print();
		
		/*!
		*  \brief Displays a bounding box in color.
		*
		*  Displays a bounding box in color.
		*  We display individually each face of the bounding box, could display only once each line instead.
		*
		*  \param _r : Red component of the color to display.
		*  \param _g : Green component of the color to display.
		*  \param _b : Blue component of the color to display.
		*
		*  \return (void)
		*/
		void display ( float _r = 1, float _g = 0, float _b = 0 );
};

#endif // BOUNDINGBOX_H
